package com.xuhao.examai.scoring.infrastructure.persistence;

import com.xuhao.examai.scoring.domain.models.AnswerRecord;
import com.xuhao.examai.scoring.domain.repositories.AnswerRecordRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class AnswerRecordRepositoryImpl implements AnswerRecordRepository {

	private final AnswerRecordJpaRepository answerRecordJpaRepository;

	@Override
	public AnswerRecord save(AnswerRecord answerRecord) {
		return answerRecordJpaRepository.save(answerRecord);
	}

	@Override
	public Optional<AnswerRecord> findById(Long id) {
		return answerRecordJpaRepository.findById(id);
	}

	@Override
	public List<AnswerRecord> findByExamRecordId(Long examRecordId) {
		return answerRecordJpaRepository.findByExamRecordId(examRecordId);
	}

	@Override
	public Optional<AnswerRecord> findByExamRecordIdAndQuestionId(Long examRecordId, Long questionId) {
		return answerRecordJpaRepository.findByExamRecordIdAndQuestionId(examRecordId, questionId);
	}

	@Override
	public List<AnswerRecord> findByQuestionId(Long questionId) {
		return answerRecordJpaRepository.findByQuestionId(questionId);
	}

	@Override
	public List<AnswerRecord> saveAll(List<AnswerRecord> answerRecords) {
		return answerRecordJpaRepository.saveAll(answerRecords);
	}

	@Override
	public void deleteById(Long id) {
		answerRecordJpaRepository.deleteById(id);
	}

	@Override
	public void deleteByExamRecordId(Long examRecordId) {
		answerRecordJpaRepository.deleteByExamRecordId(examRecordId);
	}

	@Override
	public boolean existsById(Long id) {
		return answerRecordJpaRepository.existsById(id);
	}
}